#include <iostream>
#include "Interfaces.h"


int main(){
    using namespace Terminal;
    using namespace std;

    //class Date test
    Date * date = new Date(2019, 7, 24, 10, 03, 22);
    Date * date1 = new Date(2019, 7, 24, 10, 03, 22);
    Date * date2 = new Date(2020, 8, 25, 11, 04, 23);
    cout << *date << endl;

    date->setYear(2020);
    date->setMonth(8);
    date->setDay(25);
    date->setHour(11);
    date->setMinute(04);
    date->setSecond(23);

    cout << *date << endl;
    
    date->changeTo(2019, 7, 24, 10, 03, 22);
    cout << *date << endl << endl;

    cout << date->year() << "/" << date->month() << "/" << date->day() << "\t" << date->hour() << ":" <<
    date->minute() << ":" << date->second() << endl;

    cout << date->toString() << endl;

    if( *date == *date1 )
        cout << "true" << endl;

    cout << *date - *date1 << endl;

    *date = *date2;

    cout << *date << endl;

    if(*date > *date1)
        cout << " > is OK" << endl;

    if(*date1 < *date2)
        cout << " < is OK" << endl;


    //class Task test
    Date * sDate = new Date(2019, 7, 24, 10, 25, 30);
    Date * eDate = new Date(2019, 8, 3, 10, 25, 30);
    Task * task = new Task("task2", "label2", "remarks2", sDate, eDate);
    Task * task2 = new Task("task2", "label2", "remarks2", sDate, eDate);
    Task * task3 = new Task("task3", "label3", "remarks3", sDate, eDate);
    Task * task4 = new Task("task4", "label4", "remarks4", sDate, eDate);
    Task * task5 = new Task("task5", "label5", "remarks5", sDate, eDate);
    cout << *task << endl;

    sDate->changeTo(2020, 8, 25, 11, 26, 31);
    eDate->changeTo(2020, 9, 3, 11, 26, 31);

    task->setName("task1");
    task->setLabels("label1");
    task->setRemarks("remarks1");
    task->setBegDate(sDate);
    task->setEndDate(eDate);
    task->setImportance(3);
    cout << *task << endl;
    cout << task->toString() << endl << endl;

    //add test
    cout << "Task : add task: \n";
    task->add(task2);
    task->add(task3);
    task->add(task4);
    task->add(task5);
    task->add("task6", "label6", "remarks6", sDate, eDate, 2);
    cout << *task << endl;

    //remove test
    cout << "--------------------------------------------------\n";

    cout << "Task : remove task: \n";
    task->remove("task2");
    cout << *task << endl;


    //swap test
    cout << "Task : swap task: \n";
    task5->swapWith(task5->next());
    cout << *task << endl;

    // class Plan test
    cout << "\n\n***The following is calss plan test***\n\n";
    Plan * plan  = new Plan("plan1", "label1", "remarks1");
    Plan * plan2 = new Plan("plan2", "label2", "remarks2");
    // Plan * plan3 = new Plan("plan3", "label3", "remarks3");
    // Plan * plan4 = new Plan("plan4", "label4", "remarks4");
    // Plan * plan5 = new Plan("plan5", "label5", "remarks5");
    Task * taska = new Task("taska", "labela", "remarksa", sDate, eDate);
    Task * taskb = new Task("taskb", "labelb", "remarksb", sDate, eDate);
    Task * taskc = new Task("taskc", "labelc", "remarksc", sDate, eDate);
    Task * taskd = new Task("taskd", "labeld", "remarksd", sDate, eDate);

    //add plan test
    cout << "** add plan **\n";
    plan->add(plan2);
    plan->addTask(taska);
    plan->addTask(taskb);
    // plan->add(plan3);
    plan2->addTask(taskc);
    plan2->addTask(taskd);
    // plan->add(plan4);
    // plan->add(plan5);
    cout << *plan << endl;

    //remove plan test


    cout << "_______________________________________________\n";
    Date * today = new Date(2020, 9, 1, 13, 44, 30);
    Task * todayTask = checkToday(plan, today);
    cout << *todayTask << endl;
    
    cout << "-----------------------------------------\n";
    TSave("test1.txt", plan);
    
    Plan *newH = TOpen("test1.txt");
    
    cout << *newH << endl;

    system("pause");
    return 0;
}

